// 方案1：直接监听登录按钮点击
document.addEventListener("click", (e) => {
  if (e.target.id === "login-button" || e.target.classList.contains("login-class")) {
    // 监听页面跳转或异步加载完成
    observeLoginSuccess();
  }
});

// 方案2：检测登录后页面元素变化（更可靠）
function observeLoginSuccess() {
  const observer = new MutationObserver((mutations) => {
    const successElement = document.querySelector(".welcome-message");
    if (successElement) {
      // 发送消息给后台脚本
      chrome.runtime.sendMessage({ action: "loginSuccess" });
    }
  });
  observer.observe(document.body, { childList: true, subtree: true });
}